package cn.tedu.csmailproduct.controller;

import cn.tedu.csmailproduct.ex.ServiceException;
import cn.tedu.csmailproduct.pojo.dto.AlbumAddNewDTO;
import cn.tedu.csmailproduct.pojo.dto.CategoryAddNewDTO;
import cn.tedu.csmailproduct.service.IAlbumService;
import cn.tedu.csmailproduct.service.ICategoryService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 处理分类相关请求的控制器
 *
 * @author java@qq.com
 * @version 0.0.1
 *
 */

@Api(tags = "03. 分类管理模块")
@Slf4j
@RestController
@RequestMapping("/categories")
public class CategoryController {

    @Autowired
    private ICategoryService categoryService;

    public CategoryController(){
        log.debug("创建控制器对象：CategoryController");
    }

    // http://localhost:8080/category/add-new?name=分类001&description=分类001的简介&sort=199
    @ApiOperation("添加分类")
    @ApiOperationSupport(order = 100)
    @PostMapping("/add-new")
    public String addNew(CategoryAddNewDTO categoryAddNewDTO){
        log.debug("开始处理【添加分类】的请求，参数：{}：",categoryAddNewDTO);

            categoryService.addNew(categoryAddNewDTO);
            log.debug("添加数据成功");
            return "添加分类成功！";

    }

}
